package com.edooteach.api.web.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.demo2do.core.entity.result.HttpResult;
import com.edoomath.entity.tecent.TencetAuth;
import com.edooteach.api.servcice.DataService;

/**
 * 
 * @author mohanlan
 *
 */
@Controller
@RequestMapping("/tencent-auth")
public class WechatAuthController {
    
    private static final Logger logger = LoggerFactory.getLogger(WechatAuthController.class);
    
    @Autowired
    private DataService<TencetAuth> dataService;
    
    @RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public HttpResult loadMockUser() {
        
        HttpResult httpResult = new HttpResult();
        
        try {
            
            TencetAuth tencetAuth = dataService.load(TencetAuth.class, new Long(1));
            httpResult.success().data("tencetAuth", tencetAuth).message("获取授权模拟用户成功");
            
        } catch (Exception e) {
            logger.error("get tencent auth error: ", e);
            httpResult.fail("500").message("获取授权模拟用户失败");
        }
        
        return httpResult;
    }
}
